package game.examples;

import game.Coordinate;
import game.Entity2D;
import game.Spawner2D;
import game.examples.newEntityCreation.ThreadBasedMob;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class SpawnerExample extends Spawner2D implements KeyListener, MouseListener {

	//Variabili di supporto.
	private Coordinate coo;
	private Entity2D entity;
	
	public SpawnerExample(int widthRenderables, int heightRenderables, int widthRenderArea, int heightRenderArea) {
		super(widthRenderables, heightRenderables, widthRenderArea, heightRenderArea);
	}
	
	@Override
	public void createEntity() {
		int ID = generateID();
		coo = generateFullRandomCooridates();
		entity = new ThreadBasedMob(ID, coo, 0);
		insertEntity( entity );
		entity.start();
	}
	
	@Override
	public void mousePressed(MouseEvent e) {
		int ID = generateID();
		coo = new Coordinate(e.getX(), e.getY(), 0);
		entity = new ThreadBasedMob(ID, coo, 0);
		insertEntity( entity );
		entity.start();
	}

	
	@Override
	public void keyPressed(KeyEvent e) {
		if(e.getKeyCode() == KeyEvent.VK_SPACE ){
			createEntity();
		}
	}
	
	@Override
	public void keyReleased(KeyEvent e) {
	}
	
	@Override
	public void keyTyped(KeyEvent e) {
	}

	@Override
	public void mouseClicked(MouseEvent e) {
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
	}

	@Override
	public void mouseReleased(MouseEvent e) {
	}
}
